import { RouteRecordRaw } from "vue-router";

//扩展 RouteMeta 接口
declare module 'vue-router' {
  interface RouteMeta {
    title?: string,
    transition?: string,
    requiresAuth: boolean  //是否需要登录
  }
}


const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "index",
    component: () => import("../views/portal/Index.vue"),
  },
  {
    path: "/home",
    name: "home",
    component: () => import("../views/home/Home.vue"),
    meta: {
      title: "主页",
      transition: "animate__fadeIn",
      requiresAuth: false
    },
  },
  {
    path: "/user_center",
    name: "user_center",
    component: () => import("../views/user/UserCenter.vue"),
    meta: {
      requiresAuth: true
    },
    children: [
      {
        path: '',
        name: 'favorite_list',
        component: () => import("../components/user/FavoriteList.vue"),
        meta: {
          requiresAuth: true
        }
      },
      {
        path: "/favorite/:id",
        name: 'favorite',
        component: () => import("../components/user/PhotosList.vue"),
        meta: {
          requiresAuth: true
        }
      }
    ]
  },
  {
    path: "/user/edit",
    name: "user_edit",
    component: () => import("../views/user/EditInfo.vue"),
    meta: {
      requiresAuth: true
    },
  },
];

export default routes;
